//
//  XPVisitorViewController.m
//  SinaWeibo
//
//  Created by 徐攀 on 16/5/11.
//  Copyright © 2016年 徐攀. All rights reserved.
//

#import "XPVisitorViewController.h"
#import "XPVisitorView.h"
#import "XPOAuthViewController.h"

@interface XPVisitorViewController ()


@end

@implementation XPVisitorViewController

- (void)loadView {
    
    self.isLogin ? [super loadView] : [self setupVisitorView];
}

- (void)setupVisitorView {
    self.visitorView = [[XPVisitorView alloc] initWithFrame:kScreenBounds];
    self.view = self.visitorView;
    
    __weak typeof(self) weakSelf = self;
    [self.visitorView setLoginBlock:^{
        [weakSelf oAuthLogin];
    }];
    
    self.visitorView.backgroundColor = [UIColor colorWithWhite:237.0 / 255 alpha:1.0];
    
    [self setupUI];
}

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)setupUI {
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[self buttonWithTitle:@"注册"]];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[self buttonWithTitle:@"登录"]];
}

- (UIButton *)buttonWithTitle:(NSString *)title {
    return [UIButton baseButton:title withFontSize:16 backgroundImage:nil target:self action:@selector(oAuthLogin)];
}

- (void)oAuthLogin {
    XPOAuthViewController *OAuthVC = [[XPOAuthViewController alloc] init];
    UINavigationController *OAuthNav = [[UINavigationController alloc] initWithRootViewController:OAuthVC];
    [self presentViewController:OAuthNav animated:YES completion:nil];
}


@end
